<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
<meta charset="utf-8">
<title>系统管理-讲师列表</title>
<link href="../c/base.css" rel="stylesheet" type="text/css">
<link href="../c/toefl.css" rel="stylesheet" type="text/css">
<link href="../c/bootstrap.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../j/jquery-2.1.0.js"></script>
<script type="text/javascript" src="../j/bootstrap.min.js"></script>
<script type="text/javascript" src="../j/lrtk.js"></script>
<script src="../layer/layer.js" type="text/javascript" charset="utf-8"></script>
<style>
.nowPage {
	color: red;
}
</style>

<script type="text/javascript">
	$(function() {
		var boxs = $("input[type='checkbox'][id^='box_']");
		
		$("tr[id^='data_']").hover(function() {
			$(this).css("backgroundColor", "#eeccff");
		}, function() {
			$(this).css("backgroundColor", "#ffffff");
		})

		$("#checkAll").click(function() {
			boxs.prop("checked", this.checked);
		})

		$("#close").click(function() {
			var checkedBoxs = boxs.filter(":checked");
			if (checkedBoxs.length < 1) {
				layer.alert("请选择一个需要关闭的课程！", function(index) {
					layer.close(index);
				});
			} else {
				var ids = checkedBoxs.map(function() {
					return this.value;
				})
				
				layer.confirm('你确定要关闭课程吗？', {
					title : '提示'
				}, function(index) {
					window.location = "closeCastles?ids=" + ids.get();
					layer.close(index);
				}, function() {
					layer.close();
				});
			}
			
		})
		
		$("#refresh").click(function() {
			var checkedBoxs = boxs.filter(":checked");
			if (checkedBoxs.length < 1) {
				layer.alert("请选择一个需要恢复的课程！", function(index) {
					layer.close(index);
				});
			} else {
				var ids = checkedBoxs.map(function() {
					return this.value;
				})
				
				layer.confirm('你确定要恢复课程吗？', {
					title : '提示'
				}, function(index) {
					window.location = "refreshCastles?ids=" + ids.get();
					layer.close(index);
				}, function() {
					layer.close();
				});
			}
			
		})

		$("#delete").click(function() {
			var checkedBoxs = boxs.filter(":checked");
			if (checkedBoxs.length < 1) {
				layer.alert("请选择一个需要删除的课程！", function(index) {
					layer.close(index);
				});
			} else {
				var ids = checkedBoxs.map(function() {
					return this.value;
				})
				
				layer.confirm('你确定要删除课程吗？', {
					title : '提示'
				}, function(index) {
					window.location = "delCastles?ids=" + ids.get();
					layer.close(index);
				}, function() {
					layer.close();
				});			
			}
		})

	})

	function searchCastle(pageNum, mallType) {
		$("#pageNum").attr("value", pageNum);
		$("#mallType").attr("value", mallType);
		$("#castleform").submit();
	}
</script>
</head>

<body>
	<div class="openMenu">
		<div class="doc1180">
			<ul class="fn-clear" style="padding-left: 220px;">
				<li th:class="${castleInfo.mall_type == null} ? 'openMenuOn' : ''"><a
					href="###" th:onclick="searchCastle(1, null)">全部</a></li>
				<li th:each="mallType:${mallTypes}"
					th:class="${castleInfo.mall_type == mallType.type_id} ? 'openMenuOn' : ''"
					style="float: left;"><a href="###"
					th:onclick="searchCastle(1, [[${mallType.type_id}]])">[[${mallType.type_name}]]</a>
				</li>

			</ul>
		</div>
	</div>
	<div class="doc1180 paddingT20 fn-clear container">
		<div>
			<form action="toAdminCastle" method="post" id="castleform"
				class="form-inline">
				<input type="hidden" name="pageNum" id="pageNum"
					th:value="${castleInfo.pageNum}"> <input type="hidden"
					name="mall_type" id="mallType" th:value="${castleInfo.mall_type}">
				<div class="form-group">
					<label for="exampleInputName2">课程名称</label> <input type="text"
						name="class_title" class="form-control" id="class_title"
						placeholder="Jane Doe" th:value="${castleInfo.class_title}">
				</div>
				<div class="form-group">
					<label for="exampleInputEmail2">讲师</label> <select
						class="form-control" name="teacher_id" id="teacher_id">
						<option value="">--全部讲师--</option>
						<option th:each="teacher:${teachers}"
							th:selected="${teacher.teacher_id == castleInfo.teacher_id}"
							th:value="${teacher.teacher_id}">[[${teacher.user_name}]]</option>
					</select>
				</div>
				<div class="form-group">
					<label for="exampleInputEmail2">课程类别</label> <select
						class="form-control" name="castle_type" id="castle_type">
						<option value="">--全部课程--</option>
						<option th:each="castleType:${castleTypes}"
							th:value="${castleType.type_id}"
							th:selected="${castleType.type_id == castleInfo.castle_type}">[[${castleType.type_name}]]</option>
					</select>
				</div>

				<button class="btn btn-primary" th:onclick="searchCastle(1)">搜索</button>
			</form>

		</div>
		<div class="myPost_Theme" style="height: 80vh; margin-top: 50px;">
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				class="myPost_Table">
				<tr class="myPost_Th">
					<th><input type="checkbox" name="checkAll" id="checkAll"
						value="" /></th>
					<th>课程名称</th>
					<th>活动类别</th>
					<th>课程分类</th>
					<th>讲师</th>
					<th>开始日期</th>
					<th>结束日期</th>
					<th>上课周期</th>
					<th>上课时间</th>
					<th>课程费用</th>
					<th>课程状态</th>
				</tr>
				<tr th:each="castle,iter:${pageInfo.list}" th:id="'data_' + ${iter}">
					<td><input type="checkbox" name="" th:id="'box_' + ${iter}"
						th:value="${castle.castle_id}" /></td>
					<td><a style="color: red;" href="###">[[${castle.class_title}]]</a>
					</td>
					<td>[[${castle.mallType.type_name}]]</td>
					<td>[[${castle.castleType.type_name}]]</td>
					<td>[[${castle.teacher.user_name}]]</td>
					<td>[[${#dates.format(castle.start_date, 'yyyy-MM-dd')}]]</td>
					<td>[[${#dates.format(castle.end_date, 'yyyy-MM-dd')}]]</td>
					<td>每周[[${castle.castle_cycle}]]</td>
					<td>[[${#dates.format(castle.start_time,
						'HH:mm')}]]--[[${#dates.format(castle.end_time, 'HH:mm')}]]</td>
					<td>[[${castle.castle_pay}]] rmb</td>
					<td th:if="${castle.status == '0'}">开始报名</td>
					<td th:if="${castle.status == '1'}">结束报名</td>
					<td th:if="${castle.status == '2'}">关闭</td>
					<td th:if="${castle.status == '3'}">已经结束</td>
				</tr>

			</table>

			<div class="pageList" style="width: 500px; float: right;">
				<ul>
					<li th:if="${pageInfo.pageNum != 1}"><a href="###"
						onclick="searchCastle(1)">首页</a></li>
					<li th:each="pages:${pageInfo.navigatepageNums}"><a href="###"
						th:class="${pages == pageInfo.pageNum} ? nowPage : ''"
						th:onclick="searchCastle([[${pages}]])">【[[${pages}]]】</a></li>
					<li th:if="${pageInfo.pageNum != pageInfo.pages}"><a
						href="###" th:onclick="searchCastle([[${pageInfo.pages}]])">最后一页</a></li>
					<li th:if="${pageInfo.pageNum != 1}"><a href="###"
						class="pret" th:onclick="searchCastle([[${pageInfo.prePage}]])">上一页</a></li>
					<li th:if="${pageInfo.pageNum != pageInfo.pages}"><a
						href="###" class="next"
						th:onclick="searchCastle([[${pageInfo.nextPage}]])">下一页</a></li>
				</ul>
			</div>

			<div id="" class=""
				style="margin-top: 40px; width: 400px; float: left;">
				<a href="#" class="btn btn-success" id="close">关闭</a> <a href="#"
					class="btn btn-success" id="refresh">恢复</a> <a href="#"
					class="btn btn-danger" id="delete">删除</a>
			</div>
		</div>

	</div>

	<!--表单元素-->

	<!-- 代码结束 -->
</body>

</html>